<?php
namespace Cyfy\Modules\FileManager\Forms;
use \Cyfy\Message;
use \Cyfy\Modules\Forms;

/**
 * Makes a new directory
 */
class MakeDirectory extends Forms\Form
{
	function structure()
	{		
        $this -> permission("FileManager", "use");
        $this -> stay = false; 
		
        $i = new Forms\TextBox("new",self :: t(410));
        $i -> required = true;
        $this -> addItem($i);
        
        $i = new Forms\Hidden("directory", "");
        $i -> SetId("makeDirectoryFormDirectory");
		$this -> addItem($i);
		
		$b = new Forms\Button(self :: t(420));
		$this -> addButton($b);
    }
    
	function submit()
	{  
        $this -> onSubmit = "fileManager.readDir('" . $this -> get("directory") . "', true); $('.makeDirectoryFormC').slideUp();";
        
        if(\Cyfy\Cyfy ::  makeDirectory(\Cyfy\Cyfy ::  $filesDir . $this -> get("directory") . "/" . $this -> get("new")))
        {
            \Cyfy\Message :: set(self :: t(430));
            return true;
        }
        \Cyfy\Message :: set(self :: t(440), \Cyfy\Message :: ERROR);
        return false;
	}	

}
